class Event {

    static hasMany = [ positions: Position ]
   // static belongsTo=[userAccount: UserAccount]
    String name
    String description
    String location
    UserAccount administrator
    Date startDate
    Date endDate

   static constraints = {
        name(nullable: false, unique: true, blank: false)
        description(nullable: false, size:0..50, blank: false)
        location(size:0..20)
     startDate()
     endDate(validator:{val, obj->
     return val.after(obj.startDate)
     })
        }
     def getOpenPositions(){
       getPositions().findAll { it.isOpen() }
     }     

}